class Student:
    # name
    name: str
    # 学号
    student_no: str
    # 语文成绩
    chinese_score: float
    # 英语成绩
    english_score: float
    # 所属班级
    class_no: str

    def __init__(self, name, student_no, chinese_score, english_score, class_no):
        self.name = name
        self.student_no = student_no
        self.class_no = class_no
        self.english_score = english_score
        self.chinese_score = chinese_score

    def getStudentInformation(self):
        print(self.student_no)
        print(self.name)
        print(self.chinese_score)


class App:
    def __init__(self):
        self.container = dict()
    def exam(self, stu_no, score):
        print(self.container)
        if self.container.get(stu_no) is None:
            self.container[stu_no] = [score]
        else:
            self.container[stu_no].append(score)

    def exam_avg(self, stu_no):
        my_result = 0
        for item in self.container[stu_no]:
            my_result += item
        return my_result / len(self.container[stu_no])
    # {
    #     "001": [20, 18, 22],
    #     "002": [20, 18, 22],
    #     "003": [20, 18, 22]
    # }


class Animal:
    def __init__(self, category, name, weight=0):
        self.category = category
        self.name = name
        self.weight = weight

    def run(self):
        if self.category == "water":
            print("这个动物是海洋生物")
        elif self.category == "mainland":
            print("这个动物是陆地生物")
        elif self.category == "sky":
            print("这个是飞翔生物")

    def eat(self, food):
        if food == 'A' and self.category == 'water':
            self.weight += 1
        if food == 'B' and self.category == 'mainland':
            self.weight += 2
        if food == 'C' and self.category == 'sky':
            self.weight += 0.5


class Dog(Animal):
    def call(self):
        print("wawa")


class Cat(Animal):
    def fetch(self):
        print("抓老鼠")
        self.weight += 3


if __name__ == '__main__':
    app = App()
    stu = Student('jack', student_no='stu', chinese_score=100, english_score=20, class_no='A')
    app.exam(stu.student_no, stu.chinese_score)
    stu.chinese_score = 90
    app.exam(stu.student_no, stu.chinese_score)
    stu.chinese_score = 85
    app.exam(stu.student_no, stu.chinese_score)
    stu.chinese_score = 82
    app.exam(stu.student_no, stu.chinese_score)
    stu.chinese_score = 89
    app.exam(stu.student_no, stu.chinese_score)
    stu.chinese_score = 96
    app.exam(stu.student_no, stu.chinese_score)
    stu.chinese_score = 92
    app.exam(stu.student_no, stu.chinese_score)
    stu.chinese_score = 91
    app.exam(stu.student_no, stu.chinese_score)
    result = app.exam_avg(stu.student_no)
    print('the avg: ', result)

    stu.getStudentInformation()
    fish = Animal(category='water', name='fish')
    fish.run()
    tiger = Animal(category='mainland', name='tiger')
    tiger.run()
    bridge = Animal(category='sky', name='bridge')
    bridge.run()
    fish.eat("A")
    fish.eat('A')
    print(fish.weight)

    dog = Dog(category='mainland', name='小黄', weight=10)
    dog.eat("B")
    print(dog.weight)

    cat = Cat(category='mainland', name='小花', weight=20)
    cat.fetch()
    print(cat.weight)
